using GameFramework.Fsm;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityGameFramework.Runtime;

namespace LS.Procedure
{
    public class ProcedurePreloadResources : ProcedurePreloaderBase
    {
        private bool m_InitResourcesComplete = false;
        public override bool UseNativeDialog => false;

        public override int PreloadPriority => 0;

        protected override void OnEnter(IFsm<GameFramework.Procedure.IProcedureManager> procedureOwner)
        {
            base.OnEnter(procedureOwner);
            if (LSEntry.Base.EditorResourceMode)
            {
                m_InitResourcesComplete = true;
            }
            else
            {
                LSEntry.Resource.InitResources(OnInitResourcesComplete);
            }
        }
        protected override void OnUpdate(IFsm<GameFramework.Procedure.IProcedureManager> procedureOwner, float elapseSeconds, float realElapseSeconds)
        {
            base.OnUpdate(procedureOwner, elapseSeconds, realElapseSeconds);
            if (!m_InitResourcesComplete)
            {
                return;
            }
            ChangeNextProcedure(GetNextProcedureType());
        }
        private void OnInitResourcesComplete()
        {
            m_InitResourcesComplete = true;
            Log.Info("Init resources complete.");
        }
    }
}
